<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="js/hanshu.js"></script>
</head>

<body>
    <script>
        // 使用函数实现将数组中指定的元素去掉
        let arr = [0, 10, 20, 30, 0, 40, 0];
        /* let newArr = [];
        for (let i = 0; i < arr.length; i++) {
            if (arr[i] != 0) {
                newArr[newArr.length] = arr[i]
            }
        }
        console.log(newArr); */
        /*  function arrTrip(a, b) {
             let newArr = [];
             for (let i = 0; i < a.length; i++) {
                 if (arr[i] != b) {
                     newArr[newArr.length] = arr[i]
                 }
             }
             return newArr
         } */
        let res = arrTrip(arr, 0)
        console.log(res);
    </script>
</body>

</html>